<html>
<head><meta charset="utf-8"><title>Intrinsic constness · general · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/index.html">general</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Intrinsic.20constness.html">Intrinsic constness</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="202042147"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Intrinsic%20constness/near/202042147" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Gary Guo <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Intrinsic.20constness.html#202042147">(Jun 26 2020 at 00:39)</a>:</h4>
<p><a href="https://doc.rust-lang.org/nightly/std/intrinsics/index.html#const-intrinsics">https://doc.rust-lang.org/nightly/std/intrinsics/index.html#const-intrinsics</a> reads "Note: any changes to the constness of intrinsics should be discussed with the language team. This includes changes in the stability of the constness."</p>
<p>Why would that be the case, given that intrinsics are perma-unstable?</p>



<a name="202047923"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Intrinsic%20constness/near/202047923" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Intrinsic.20constness.html#202047923">(Jun 26 2020 at 02:58)</a>:</h4>
<p>Not all intrinsics are perma-unstable</p>



<a name="202054095"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Intrinsic%20constness/near/202054095" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Philipp Korber <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Intrinsic.20constness.html#202054095">(Jun 26 2020 at 05:27)</a>:</h4>
<p>But aren't stabilized intrinsics a problem with supporting other backends? Like cranelift for fast debug builds or in the (far?) future potential gcc.</p>



<a name="202054207"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Intrinsic%20constness/near/202054207" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Philipp Korber <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Intrinsic.20constness.html#202054207">(Jun 26 2020 at 05:30)</a>:</h4>
<p>Well I guess some intrinsics like copy, copy_nonoverlapping or transmute will always be available.</p>



<a name="202056827"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Intrinsic%20constness/near/202056827" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Intrinsic.20constness.html#202056827">(Jun 26 2020 at 06:34)</a>:</h4>
<p>many arch intrinsics can also become const at some point.</p>



<a name="202066476"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Intrinsic%20constness/near/202066476" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Intrinsic.20constness.html#202066476">(Jun 26 2020 at 08:54)</a>:</h4>
<p>Other than the LLVM intrinsics used for the implementation of most functions in <code>core::arch</code>, I have implemented most intrinsics in cg_clif. Those missing are just because I haven't implemented them yet.</p>



<a name="202066522"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Intrinsic%20constness/near/202066522" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Intrinsic.20constness.html#202066522">(Jun 26 2020 at 08:55)</a>:</h4>
<p><a href="https://github.com/bjorn3/rustc_codegen_cranelift/blob/58ffc47bbf759fa8fd9d51a67fe4a277984054ad/src/intrinsics/mod.rs">https://github.com/bjorn3/rustc_codegen_cranelift/blob/58ffc47bbf759fa8fd9d51a67fe4a277984054ad/src/intrinsics/mod.rs</a></p>



<a name="202076659"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Intrinsic%20constness/near/202076659" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Gary Guo <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Intrinsic.20constness.html#202076659">(Jun 26 2020 at 11:05)</a>:</h4>
<p><span class="user-mention silent" data-user-id="224471">Lokathor</span> <a href="#narrow/stream/122651-general/topic/Intrinsic.20constness/near/202047923">said</a>:</p>
<blockquote>
<p>Not all intrinsics are perma-unstable</p>
</blockquote>
<p>I thought all instrinsics are unstable but can be exposed in other ways? There are stable intrinsics now but they cannot be used directly because <code>std::intrinsics</code> is itself unstable.</p>



<a name="202079381"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Intrinsic%20constness/near/202079381" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Intrinsic.20constness.html#202079381">(Jun 26 2020 at 11:39)</a>:</h4>
<p><code>std::mem::transmute</code> is a re-export of <code>std::intrinsics::transmute</code> (<code>pub mod mem { pub use std::intrinsics::transmute; }</code>), not a wrapper around it.</p>



<a name="202079969"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Intrinsic%20constness/near/202079969" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Intrinsic.20constness.html#202079969">(Jun 26 2020 at 11:48)</a>:</h4>
<p>Which is the easiest way to emit a compilation error on <code>size_of::&lt;T&gt;() != size_of::&lt;U&gt;()</code> afaik</p>



<a name="202093126"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Intrinsic%20constness/near/202093126" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Intrinsic.20constness.html#202093126">(Jun 26 2020 at 13:56)</a>:</h4>
<p>And all of <code>core::arch</code> is intrinsics, including hundreds of stable functions</p>



<a name="202093822"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Intrinsic%20constness/near/202093822" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Intrinsic.20constness.html#202093822">(Jun 26 2020 at 14:00)</a>:</h4>
<p>All public functions <code>core::arch</code> are wrappers around intrinsics, inline asm or in some cases even just regular code when LLVM is able to pattern match it.</p>



<a name="202097594"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Intrinsic%20constness/near/202097594" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Intrinsic.20constness.html#202097594">(Jun 26 2020 at 14:29)</a>:</h4>
<p><span class="user-mention silent" data-user-id="303710">Gary Guo</span> <a href="#narrow/stream/122651-general/topic/Intrinsic.20constness/near/202042147">said</a>:</p>
<blockquote>
<p><a href="https://doc.rust-lang.org/nightly/std/intrinsics/index.html#const-intrinsics">https://doc.rust-lang.org/nightly/std/intrinsics/index.html#const-intrinsics</a> reads "Note: any changes to the constness of intrinsics should be discussed with the language team. This includes changes in the stability of the constness."</p>
<p>Why would that be the case, given that intrinsics are perma-unstable?</p>
</blockquote>
<p>Intrinsics are typically operations that cannot be implemented otherwise -- they are intrinsic to the language, just like <code>match</code> or the <code>+</code> operator. they happen to be exposed as function calls but should not be mistaken for normal library functions. Adding such new language primitives is clearly lang team territory.</p>



<a name="202097696"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Intrinsic%20constness/near/202097696" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Intrinsic.20constness.html#202097696">(Jun 26 2020 at 14:30)</a>:</h4>
<p>adding an intrinsic often fundamentally extends the expressiveness of what Rust can do, and that is one of the areas the lang team is responsible for</p>



<a name="202097732"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Intrinsic%20constness/near/202097732" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Intrinsic.20constness.html#202097732">(Jun 26 2020 at 14:30)</a>:</h4>
<p>making an intrinsic const fundamentally extends what CTFE can do, and thus the lang team should be involved for the same reason</p>



<a name="202097830"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Intrinsic%20constness/near/202097830" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Intrinsic.20constness.html#202097830">(Jun 26 2020 at 14:31)</a>:</h4>
<p>this applies even if the intrinsic is only indirectly exposed -- the intrinsic behind <code>write_volatile</code> is technically unstable, but the stable method could not be implemented without the intrinsic so this makes no difference re: being a language extension</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>